import { FC, ReactElement } from 'react'

import PrivateRoute from './privateRoute'

export interface WrapperRouteProps {
  element: ReactElement;
  titleId?: string;
  auth?: boolean;
}

const WrapperRouteComponent: FC<WrapperRouteProps> = ({ titleId, auth = true, ...props }) => {
  if (titleId) {
    document.title = titleId
  }

  return auth ? <PrivateRoute {...props} /> : props.element
}

export default WrapperRouteComponent
